/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package verins.Utils;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

/**
 *
 * @author Hector
 */
public class Verificador {


     public static  KeyAdapter verificaSoloNumeros(){
        return new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent evt){
                char caract=evt.getKeyChar();
                if ((caract<'0')||(caract>'9')&&(caract!=KeyEvent.VK_BACK_SPACE))
                evt.consume();
            }
        };
    }


      public static  KeyAdapter verificaSoloLetras(){
        return new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent evt){
                char caract=evt.getKeyChar();
                if ((((caract>='a')&&(caract<='z'))
                        ||((caract>='A')&&(caract<='Z'))
                        || (caract==KeyEvent.VK_BACK_SPACE)
                        || (caract==KeyEvent.VK_SPACE))){

                }else
                    evt.consume();
            }
        };
    }

      // numeros, letras,'-'
       public static  KeyAdapter verificaSoloCaracteresValidos(){
        return new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent evt){
                char caract=evt.getKeyChar();

                if (!(caract==KeyEvent.VK_SPACE
                     || caract=='-'
                     || caract==KeyEvent.VK_BACK_SPACE
                     || ((caract>='0') && (caract<='9'))
                     || ((caract>='A') && (caract<='Z'))
                     || ((caract>='a') && (caract<='z'))
                     )){
                    
                    evt.consume();
                   
                }else{
                    // System.out.println(caract);
                }
            }
        };
    }
}
